import java.io.*;

/**
 * @Description:
 * @Author:AMark
 * @Date: 10/31/2023
 */
public class test {
    public static void main(String[] args) throws FileNotFoundException {

        // 读取文件
        try (FileInputStream fis = new FileInputStream("test.txt");
             InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
             BufferedReader br = new BufferedReader(isr)) {
            String line;
            while ((line = br.readLine()) != null) {
                System.out.println(line);
            }
        } catch (IOException e) {

            e.printStackTrace();
        }

// 写入文件
        try (FileOutputStream fos = new FileOutputStream("output.txt");
             OutputStreamWriter osw = new OutputStreamWriter(fos, "GBK");
             BufferedWriter bw = new BufferedWriter(osw)) {
            bw.write("中文测试");
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
